import request from '@/utils/request'
import downloadService from '@/utils/downloadService'

// 查询分类列表
export function listCategory(query) {
  return request({
    url: '/content/category/list',
    method: 'get',
    params: query
  })
}

// 查询分类列表
export function listAllCategory() {
  return request({
    url: '/content/category/listAllCategory',
    method: 'get'
  })
}
// 查询分类详细
export function getCategory(id) {
  return request({
    url: '/content/category/' + id,
    method: 'get'
  })
}

// 新增分类
export function addCategory(name,description) {
  return request({
    url: '/admin/category/addCategory',
    method: 'post',
    params:{
      name:name,
      description:description
    }
  })
}

// 修改分类
export function updateCategory(id,name,description) {
  return request({
    url: '/admin/category/updateCategory',
    method: 'post',
    params:{
      id:id,
      name:name,
      description:description
    }
  })
}

// 删除分类
export function delCategory(id) {
  return request({
    url: '/admin/category/deleteCategory/' + id,
    method: 'delete'
  })
}

// 导出分类
export function exportCategory() {
  return downloadService({
    url: '/content/category/export',
    method: 'get'
  })
}
export function getCate(page,size) {
  return request({
    url: '/admin/category/getCategoryList',
    method: 'post',
    params:{
      page:page,
      size:size
    }
  })
}

export function getCategoryById(id) {
  return request({
    url: '/admin/category/getCategoryById',
    method: 'post',
    params:{
      id:id
    }
  })
}
export function searchCategory(name,page,size) {
  return request({
    url: '/admin/category/searchCategory',
    method: 'post',
    params:{
      name:name,
      page:page,
      size:size,
    }
  })
}

